#include <iostream>
#include <list>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    if (n<=0) return 0;
    list<int> cir;
    for (int i=1; i<=n; ++i) cir.push_back(i);

    auto it = cir.begin();
    for (int i=1; i<n; ++i)
    {
        for (int cnt = 1; cnt!=m; ++cnt)
        {
            ++it;
            if(it == cir.end()) it = cir.begin();
        }
        cout << *it << " ";
        it = cir.erase(it);
        if(it == cir.end()) it = cir.begin();
    }
    cout << *it;
    return 0;
}
